<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>新闻评论列表</title>
    <script th:src="@{/js/jquery/jquery-3.6.0.js}" type="text/javascript"></script>
    <script th:src="@{/layui/layui.js}" type="text/javascript"></script>
    <script type="text/javascript" src="/xadmin/js/xadmin.js"></script>

    <link rel="stylesheet" th:href="@{/layui/css/layui.css}"/>
    <link rel="stylesheet" th:href="@{/xadmin/css/xadmin.css}"/>
    <link rel="stylesheet" th:href="@{/layui/css/modules/layer/default/layer.css}"/>

    <style type="text/css">
        .layui-table {
            text-align: center;
        }

        .layui-table th {
            text-align: center;
        }
        /*.per-line3{*/
        /*    width: 400px;*/
        /*    overflow: hidden;*/
        /*    line-height: 32px;*/
        /*    display: -webkit-box;*/
        /*    -webkit-line-clamp: 3;*/
        /*    -webkit-box-orient: vertical;*/
        /*}*/

    </style>
</head>
<body>

<div class="x-nav">
      <span>
        <a href="">首页&nbsp&nbsp  /</a>
        <a href="/back/comment/comManage">&nbsp&nbsp新闻评论列表</a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="/back/comment/comManage"
       title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>


<div class="x-body">
    <!--    查询条件-->
    <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so" action="/back/comment/comManage">
            <div class="layui-inline">
                <label class="layui-form-label">用户等级:</label>
                <div class="layui-input-block">
                    <select name="lid">
                        <!--     selected        不选择为0默认查询所有等级-->
                        <option value="">请选择用户等级</option>
                        <option value="1">1</option>
                        <option th:if="${session.back_user.lid} eq '3'" value="2">2</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline" style="padding-left: 10px;">
                <label class="layui-form-label">用户账号:</label>
                <input class="layui-input" placeholder="请输入查询的用户账号" name="uname">
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">是否违规:</label>
                <div class="layui-input-block">
                    <select name="illegal">
                        <option value="">请选择是否违规</option>
                        <option value="1">是</option>
                        <option value="0">否</option>
                    </select>
                </div>
            </div>
            <button class="layui-btn" lay-submit="" lay-filter="search"><i class="layui-icon">&#xe615;</i></button>
        </form>
    </div>

    <!--    数据表格-->
    <table class="layui-table">
        <thead>
        <th>序号</th>
        <th>用户账号</th>
        <th>用户等级</th>
        <th style="width: 400px;">用户评论</th>
        <th>是否违规</th>
        <th>评论时间</th>
        <th>操作</th>
        </thead>

        <tbody>
        <tr th:each="comment,stat:${comPage.records}" th:if="${comment.user.uname != null}">

            <td th:text="${stat.count}">序号</td>
            <td th:text="${comment.user.uname}">用户账号</td>
            <td th:text="${comment.user.lid}">用户等级</td>
            <td th:utext="${comment.content}" style="width: 400px;overflow: hidden;line-height: 32px; display: -webkit-box; -webkit-line-clamp: 2;-webkit-box-orient: vertical;">评论内容</td>
            <td th:text="${comment.illegal==0?'否':'是'}">是否违规</td>
            <td th:text="${#dates.format(comment.comTime, 'yyyy-MM-dd HH:mm')}">评论时间</td>
            <td>
                <a class="layui-btn layui-btn-xs"
                   th:onclick="x_admin_show('查看新闻','/back/comment/view?comid=[[${comment.comid}]]')">查看</a>
                <a class="layui-btn layui-btn-danger layui-btn-xs" th:onclick="delCom(this,[[${comment.comid}]])">删除</a>
            </td>
        </tr>
        </tbody>
    </table>
<!--    分页-->
    <div id="pages">
        <div class="layui-box layui-laypage layui-laypage-default">
            <a  th:href="@{/back/comment/comManage(pn=${comPage.current}-1)}"
                th:class="${comPage.current==1?'layui-laypage-prev layui-disabled':''}" >上一页</a>

            <span th:class="layui-laypage-curr" th:if="${comTotalPage} eq '1'">
                <em class="layui-laypage-em"></em><em>1</em>
            </span>

            <span th:if="${comTotalPage} gt '1'" th:class="${num==comPage.current?'layui-laypage-curr':''}"
                  th:each="num:${#numbers.sequence(1,comPage.pages)}">
                <a th:href="@{/back/comment/comManage(pn=${num})}"><em class="layui-laypage-em"></em><em>[[${num}]]</em></a>
            </span>

            <a th:href="@{/back/comment/comManage(pn=${comPage.current}+1)}"
               th:class="${comPage.current==comPage.getPages()?'layui-laypage-next layui-disabled':''}">下一页</a>

            <span class="layui-laypage-count">当前第 [[${comPage.current}]] 页，总计 [[${comPage.pages}]] 页,
                共 [[${comPage.total}]] 条记录</span>
        </div>
    </div>
</div>
<script>
    //用户新闻删除
    function delCom(obj,comid){
        layer.confirm('确认要删除吗？',function(index){
            //发异步删除数据
            $.post("/back/comment/deleteComment",{"comid":comid},function (data) {
                if(data =='success'){
                    layer.msg('删除成功!',{icon:1,time:2000});
                    setTimeout(function () {window.location.href='/back/comment/comManage';},2000);

                }else {
                    layer.msg('删除失败!',{icon:0,time:2000});
                    setTimeout(function () {window.location.href='/back/comment/comManage';},2000);
                }
            });
        });
    }

</script>


</body>
</html>